/*
 * JobPoll.h
 *
 *   Created on: 2010-3-30     
 *  Description: 由Conn向之中添加Job，多线程执行，并回调conn.handle(WRITE)进行写入
 *    Copyright: 2010 @ ICT Li Heyuan
 */

#ifndef JOBPOLL_H_
#define JOBPOLL_H_

#include "Job.h"

#include <pthread.h>

#include <list>
using std::list;

class JobPoll
{
public:
	JobPoll();
	virtual ~JobPoll();

	//向工作池中添加Job
	void addJob(Conn *conn);

private:
	//worker的线程体
	void thread_func_worker(void *arg);

	//master的线程体
	void thread_func_master(void *arg);

private:
	//需要执行的rpcMethod的任务
	list<Job> _jobs;

	//锁,同步_jobs
	pthread_mutex_t _mutex_jobs;

	//条件变量
	pthread_cond_t _cond_new_job;
};

#endif /* JOBPOLL_H_ */
